import useRequest from "@/app/utils/axiosRequest";
import ToastUtil from "@/app/utils/toastUtil";


/**
 * 获取笔记列表
 * @param shareId
 * @param type
 * @param refreshType
 * @constructor
 */
export default async function ShareModifyService(shareId: string, type: number, refreshType: (number | 0 | 1)) {
    //axios统一配置中心
    const axiosInstance = useRequest();
    /*获取笔记目录*/
    return await axiosInstance.put("/share/share/modify", {
        "shareId": shareId, /*目录ID*/
        "type": type
    }).then(response => {
        const data = response.data;
        if (!data.status) {
            ToastUtil(data.message, '❎', "error")
        } else {
            ToastUtil(data.message, '🤙', "success")
            if (refreshType === 1) {
                PubSub.publish("refreshShare", true)
            } else if (refreshType === 0) {
                PubSub.publish("refreshNote", true)
            } else {
                PubSub.publish("refreshShare", true)
                PubSub.publish("refreshNote", true)
            }
        }
        return true;
    }).catch(error => {
        return false;
    });
}